from flask import Flask
from models import db
from flask_cors import CORS
from views.admin import admin_bp
from apscheduler.schedulers.background import BackgroundScheduler

def my_app(cert):

    flask_app = Flask(__name__)

    flask_app.config.from_object(cert)

    # 注册蓝图
    flask_app.register_blueprint(admin_bp)

    # 注册模型类
    db.init_app(flask_app)

    # 注册跨域
    dada = CORS(flask_app)

    # 1. 实例化调度器
    scheduler = BackgroundScheduler()

    # 2.吧调度器添加到flask核心对象上
    flask_app.schedul = scheduler

    # 3.启动调度器
    flask_app.schedul.start()
    return flask_app






